isImportantForAutofill
Hints the Android System whether the android.app.assist.AssistStructure.ViewNode associated with this view is considered important for autofill purposes.
Generally speaking, a view is important for autofill if:
- The view can be autofilled by an android.service.autofill.AutofillService.
- The view contents can help an android.service.autofill.AutofillService determine how other views can be autofilled.
For example, view containers should typically return false
for performance reasons (since the important info is provided by their children), but if its properties have relevant information (for example, a resource id called credentials
, it should return true
. On the other hand, views representing labels or editable fields should typically return true
, but in some cases they could return false
(for example, if they're part of a "Captcha" mechanism).
The value returned by this method depends on the value returned by getImportantForAutofill:
- if it returns IMPORTANT_FOR_AUTOFILL_YES or IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, then it returns
true
- if it returns IMPORTANT_FOR_AUTOFILL_NO or IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, then it returns
false
- if it returns IMPORTANT_FOR_AUTOFILL_AUTO, then it uses some simple heuristics that can return
true
in some cases (like a container with a resource id), butfalse
in most. - otherwise, it returns
false
.
When a view is considered important for autofill:
- The view might automatically trigger an autofill request when focused on.
- The contents of the view are included in the android.view.ViewStructure used in an autofill request.
On the other hand, when a view is considered not important for autofill:
- The view never automatically triggers autofill requests, but it can trigger a manual request through requestAutofill.
- The contents of the view are not included in the android.view.ViewStructure used in an autofill request, unless the request has the AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS flag.
This method is only supported on API >= 26. On API 25 and below, it will always return true
.
Return
whether the view is considered important for autofill.
Parameters
The View against which to invoke the method.